//
//  WYCAddBankController.m
//  信用卡管理
//
//  Created by 中企互联 on 2017/11/22.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCAddBankCardController.h"
#import "WYCRepaymentController.h"
#import "WYCAddPhotoController.h"
#import "WYCDetailCardController.h"
#import "WYCAddDebitbankController.h"

@interface WYCAddBankCardController ()

/** 正面按钮*/
@property(nonatomic,strong)UIButton * cardButton;

/** 反面按钮*/
@property(nonatomic,strong)UIButton * cardsideButton;

/** 反面按钮*/
@property(nonatomic,strong)UIButton * holdButton;
@end

@implementation WYCAddBankCardController

- (void)viewDidLoad {
    [super viewDidLoad];
    //Nav按钮及颜色    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cardtest) name:@"card" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cardsidetest) name:@"bankside" object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(holdsidetest) name:@"holdBank" object:nil];
    
    //界面布局
    [self setupcreat];
}

- (void)cardsidetest{
    [_holdButton setTitle:@"已认证" forState:UIControlStateNormal];
    [_holdButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [_holdButton setTitleColor:WYCRGBColor(228, 5, 67) forState:UIControlStateNormal];
    _holdButton.enabled = NO;
    
}
- (void)cardtest{
    [_cardButton setTitle:@"已认证" forState:UIControlStateNormal];
    [_cardButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    [_cardButton setTitleColor:WYCRGBColor(228, 5, 67) forState:UIControlStateNormal];
    _cardButton.enabled = NO;
}
//界面布局
- (void)setupcreat{
    UIView * backView = [[UIView alloc] init];
    backView.frame = CGRectMake(0, NavHeight, ScreenWidth, 280 * px);
    backView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:backView];
    
    //信用卡正面
    UILabel * PositiveLabel = [[UILabel alloc] init];
    PositiveLabel.frame = CGRectMake(40 * px, 40 * px, 300 * px, 72 * px);
    PositiveLabel.font = [UIFont systemFontOfSize:MiddleFont];
    PositiveLabel.text = @"银行卡正面";
    [backView addSubview:PositiveLabel];
    
    //分割线
    UIView * pline = [[UIView alloc] init];
    pline.frame = CGRectMake(40 * px, CGRectGetMaxY(PositiveLabel.frame) + 40 * px, ScreenWidth, 1);
    pline.backgroundColor = WYCRGBColor(242, 242, 242);
    [backView addSubview:pline];
    
    
    //是否扫描
    UIButton * cardButton = [[UIButton alloc] init];
    cardButton.frame = CGRectMake(backView.width  - 180 * px, PositiveLabel.y, 100 * px, PositiveLabel.height);
    cardButton.titleLabel.font = [UIFont systemFontOfSize:30 * px];
    [cardButton setImage:[UIImage imageNamed:@"scanning"] forState:UIControlStateNormal];
    [cardButton addTarget:self action:@selector(cardButtonClick) forControlEvents:UIControlEventTouchUpInside];
    cardButton.titleLabel.font = [UIFont systemFontOfSize:30 * px];
    [backView addSubview:cardButton];
    self.cardButton = cardButton;
    
    
    
    
    
    
    /**********************
     *****手持信用卡正面*****
     **********************/
    
    //信用卡反面
    UILabel * holdLabel = [[UILabel alloc] init];
    holdLabel.frame = CGRectMake(40 * px, CGRectGetMaxY(pline.frame) + 40 * px, 500 * px, 72 * px);
    holdLabel.font = [UIFont systemFontOfSize:MiddleFont];
    holdLabel.text = @"手持信用卡正面";
    [backView addSubview:holdLabel];
    
    //分割线
    UIView * hline = [[UIView alloc] init];
    hline.frame = CGRectMake(40 * px, CGRectGetMaxY(holdLabel.frame) + 40 * px, ScreenWidth, 1);
    hline.backgroundColor = WYCRGBColor(242, 242, 242);
    [backView addSubview:hline];
    
    //是否扫描
    UIButton * holdcardButton = [[UIButton alloc] init];
    holdcardButton.frame = CGRectMake(backView.width  - 180 * px, holdLabel.y, 100 * px, PositiveLabel.height);
    [holdcardButton setImage:[UIImage imageNamed:@"Photograph"] forState:UIControlStateNormal];
    [holdcardButton addTarget:self action:@selector(holdcardButtonClick) forControlEvents:UIControlEventTouchUpInside];
    holdcardButton.titleLabel.font = [UIFont systemFontOfSize:30 * px];
    [backView addSubview:holdcardButton];
    self.holdButton = holdcardButton;
    
    
    
    //提示
    UILabel * messege = [[UILabel alloc] init];
    messege.frame = CGRectMake(40 * px, CGRectGetMaxY(backView.frame) + 80 * px, ScreenWidth - 80 * px, PositiveLabel.height);
    messege.textAlignment = NSTextAlignmentCenter;
    messege.textColor = WYCRGBColor(123, 123, 238);
    messege.font = [UIFont systemFontOfSize:SmallFont];
    messege.text = @"手持信用卡请完全漏出手臂，确保信用卡号码等信息清晰可见";
    [self.view addSubview:messege];
    
    
    //提交按钮
    UIButton *SubmitButton = [[UIButton alloc] init];
    SubmitButton.frame = CGRectMake(40 * px, CGRectGetMaxY(messege.frame) + 160 * px, ScreenWidth - 80 * px, 160 * px);
    SubmitButton.layer.cornerRadius = 5;
    SubmitButton.backgroundColor = WYCMain;
    [SubmitButton setTitle:@"提交" forState:UIControlStateNormal];
    [SubmitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [SubmitButton addTarget:self action:@selector(submitButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:SubmitButton];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCMain;
    [self.view addSubview:NavView];
    
    
    
    CALayer *bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = WYCRGBColor(191, 191, 196).CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
    //返回按钮
    UIButton *  backbutton = [[UIButton alloc] init];
    [backbutton setImage:[UIImage imageNamed:@"Nav_back"] forState:UIControlStateNormal];
    [backbutton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    backbutton.frame = CGRectMake(30 * px, titleY, 66 * px , 66 * px);
    [NavView addSubview:backbutton];
    
    
    UILabel * NavRigsterLabel = [[UILabel alloc] init];
    NavRigsterLabel.frame = CGRectMake(0, titleY, NavView.width, 68 * px);
    NavRigsterLabel.textColor = [UIColor whiteColor];
    NavRigsterLabel.font = [UIFont boldSystemFontOfSize:BigFont];
    NavRigsterLabel.textAlignment = NSTextAlignmentCenter;
    NavRigsterLabel.text = @"添加银行卡";
    [NavView addSubview:NavRigsterLabel];
}
- (void)backClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}




- (void)submitButtonClick{
    if (![_cardButton.titleLabel.text isEqualToString:@"已认证"]) {
        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"请扫描银行卡正面"];
        return;
    }else if (![_holdButton.titleLabel.text isEqualToString:@"已认证"]) {
        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"请上传手持银行卡照片"];
        return;
    }else{
        [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"提交成功"];
    }
}





#pragma make --------->>正面
- (void)cardButtonClick{
    WYCAddDebitbankController * showimage = [[WYCAddDebitbankController alloc] init];
    showimage.strType = @"1";
    [self.navigationController pushViewController:showimage animated:NO];
    
}

#pragma make --------->>手持
- (void)holdcardButtonClick{
    
    WYCAddDebitbankController * showimage = [[WYCAddDebitbankController alloc] init];
    showimage.strType = @"2";
    [self.navigationController pushViewController:showimage animated:NO];
}


@end


